package sliding_window

type deque struct {
	indexes []int
}

func newDeque() *deque {
	return &deque{
		indexes: make([]int, 0),
	}
}
func (d *deque) push(i int) {
	d.indexes = append(d.indexes, i)
}

func (d *deque) getFirst() int {
	return d.indexes[0]
}

func (d *deque) popFirst() int {
	f := d.indexes[0]
	d.indexes = d.indexes[1:]
	return f
}

func (d *deque) getLast() int {
	return d.indexes[len(d.indexes)-1]
}

func (d *deque) popLast() {
	d.indexes = d.indexes[:len(d.indexes)-1]
}

func (d *deque) empty() bool {
	return 0 == len(d.indexes)
}

func (d *deque) size() int {
	return len(d.indexes)
}
